<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*, java.util.*" %>
<%
	request.setCharacterEncoding("euc-kr");

	String num=request.getParameter("num");
	String pass=request.getParameter("pass");
	
	Class.forName("com.mysql.jdbc.Driver");
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	try{
		String jdbcDriver = "jdbc:mysql://localhost:3306/coffee?"
				+ "useUnicode=true&characterEncoding=euckr";
		String dbUser = "root";
		String dbPass = "123456";
	
		
		conn = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);

		String strSQL = "select pass from RVboard where num=?";
		
		pstmt = conn.prepareStatement(strSQL);
		pstmt.setInt(1, Integer.parseInt(num));
		
		rs = pstmt.executeQuery();
		rs.next();
		
		String goodpass = rs.getString("pass").trim();
		
		if(pass.equals(goodpass))
		{
			strSQL = 
			"delete from RVboard where num=?";
			pstmt=conn.prepareStatement(strSQL);
			pstmt.setInt(1, Integer.parseInt(num));
			pstmt.executeUpdate();
			
			response.sendRedirect("listboard.jsp");
		}else
		{
			response.sendRedirect("delete_pass.jsp?num="+num);
		}
	}catch(SQLException ex){
		out.println(ex.getMessage());
	}finally{
		if(pstmt != null) try{pstmt.close();} catch(SQLException ex){}
		if(conn != null) try{conn.close();} catch(SQLException ex){}
	}
%>